<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>短信营销2-批次</title>
    <link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=path%>/hplus/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/dataTables/css/jquery.dataTables.min.css"/>
    <link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
	<link href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="<%=path%>/css/mushroom.css" rel="stylesheet">
    <style> 
        .col-sm-1{
            font-weight: normal;
        }
        
        .caoZuo{font-size: 15px;margin: 0 4px;color:#1ab394}
        table.dataTable tbody th, table.dataTable tbody td{
        padding:0;
        }
        
        table.dataTable tbody th, table.dataTable tbody td{
        padding-left:10;
        }  
        
        .aaa .radio{
        	display:inline-block;
        	float:left;
        } 
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="ibox-content col-md-12">
            <form class="form-horizontal">
                <div class="col-sm-3">
                    <div class="input-group">
                        <input id="keyWord" type="text" placeholder="批次名称搜索" class="input form-control">
                        <span class="input-group-btn">
                            <button onclick="javascript:search();" type="button" class="btn btn btn-primary"> <i class="fa fa-search"></i> 搜索</button>
                        </span>
                    </div>
                </div>

                <label class="col-sm-1 control-label">发送状态</label>
                <div class="col-sm-2">
                    <select id="select_status" class="form-control" name="account" onchange="statusChange()">
                        <option value="">全部</option>
                        <option value="6">审核通过</option>
                        <option value="1">发送完毕</option>
                        <option value="0">未提交审核</option>
                        <option value="3">发送中</option>
                        <option value="2">审核中</option>
                        <option value="4">审核未通过</option>
                        
                    </select>
                </div>      
                
                <label class="col-sm-1 control-label">创建类型</label>
                <div class="col-sm-2">
                    <select id="selectType" class="form-control" name="account" onchange="typeChange()">
                        <option value="">全部</option>
                        <option value="0">短信群发</option>
                        <option value="1">自动化营销</option>
                    </select>
                </div>

                <div class="col-sm-3 text-right">
                    <shiro:hasPermission name="information_send_many:create">
                        <button type="button" class="btn btn-w-m btn-info"
                                onclick="window.location.href='<%=path%>/view/sms/choseSendObject?type=create'"
                                style="margin-right:20px">新创建
                        </button>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="information_send_many:batch_delete">
                        <button onclick="javascript:deletedBatchDialog();" class="btn btn-primary pull-right"
                                type="button">批量删除
                        </button>
                    </shiro:hasPermission>
                </div>
            </form>
             <div class="col-sm-12" style="margin-top:20px;">
                <div class="ibox float-e-margins">
                    <div class="table-responsive">
                        <table class="display  table-striped table-bordered table-hover" id="mydataTable">
                            <thead>
                                <tr>
                                    <td>
                                        <div class="checkbox i-checks"><label class="select_all"><input  type="checkbox" ></label></div>
                                        <!-- <input type="checkbox" class="i-checks" name="input[]"> -->
                                        
                                    </td>
                                    <th>批次名称</th>
                                    <th class="sendTotal" >发送总数</th>
                                    <th>发送状态</th>
                                    <th class="sendTime">发送日期</th>
                                    <th>操作列</th>
                                </tr>
                            </thead>
                            <tbody style="font-size:15px">
                               
                            </tbody>
                        </table>
                        
                    </div>                 
                </div>
            </div>
        </div>      
    </div>
    
    <div hidden="" class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog"  aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header" style="padding: 15px 15px 10px;">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="text-left">派送</h4>
                </div>
                <div class="text-center" style="width:100%;height:60px;">                    
                    <form method="get" class="form-horizontal col-sm-12" style="margin-top:30px;">
                         <div class="form-group aaa" >
		                        <div class="radio i-checks">
		                            <label class="operation">
		                                <input type="radio" checked="true" id="send_now" name="b"> <i></i> 立即派送</label>
		                        </div>
		                        <div class="radio i-checks" style="margin-right:10px;">
		                            <label class="operation">
		                                <input type="radio" id="send_timer" name="b"> <i></i> 定时派送</label>
		                        </div>
		                       <div class="form-group" id="data_1">
			                        <div class="col-sm-5 input-group date" style="float:left;">
		                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
		                                <input id="sendTimer" type="text" class="form-control" >
		                            </div>
		                            
			                    </div>
		                </div>
                    </form>
                </div>
                <div style="display: none;">
                    <%--测试调试使用--%>
                    <label>设置定时发送的具体时间，格式为value="12:00:00"</label>
                    <input id="timestr" value=""/>
                </div>
                 <div class="modal-footer" style="text-align:center;border-top:none;">
                 <button onclick="javascript:colseModal();" type="button" class="btn btn-primary k_verify">取消</button>
                 
                     <button onclick="javascript:sendBatch();" type="button" class="btn btn-primary k_verify">发送</button>
                 </div>
             </div>
        </div>
    </div> 
  <script src="<%=path%>/hplus/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=path%>/hplus/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="<%=path%>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=path%>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=path%>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=path%>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=path%>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=path%>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=path%>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
    <script src="<%=path%>/hplus/js/plugins/cropper/cropper.min.js"></script>
    
    <script type="text/javascript" src="<%=path%>/hplus/js/plugins/dataTables/jquery.dataTables.min.js"></script>
    <script src="<%=path%>/hplus/js/demo/form-advanced-demo.min.js"></script>
	<script src="<%=path%>/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>

    <script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
	   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/loading.js"></script>

    <script type="text/javascript">
    $('.select_all').on('ifChecked', function(event){
    	$(".childCheckbox").attr("checked","checked"); 
		$(".childCheckbox").parent().addClass("checked");
		idsList.length=0;
		$('.childCheckbox').each(function(i, d){
			var id=$(this).val();
			
			idsMap.set(id,id);
		})
		idsMap.forEach(function (element, index, array) {
 		    // element: 指向当前元素的值
 		    // index: 指向当前索引
 		    // array: 指向Array对象本身modelIds
 			 idsList.push(element);
 		});
		
    });
    $('.select_all').on('ifUnchecked', function(event){
    	$(".childCheckbox").removeAttr("checked","checked"); 
		$(".childCheckbox").parent().removeClass("checked");
		idsList.length=0;
		$('.childCheckbox').each(function(i, d){
			var id=$(this).val();
			idsMap.delete(id);
		})
		idsMap.forEach(function (element, index, array) {
 		    // element: 指向当前元素的值
 		    // index: 指向当前索引
 		    // array: 指向Array对象本身modelIds
 			 idsList.push(element);
 		});
    });
    
    
    
    $(document).on('ifChecked', '.childCheckbox', function() {
    	$(this).attr("checked","checked"); 
		$(this).parent().addClass("checked");
		var id=$(this).val();
		idsList.length=0;
		idsMap.set(id,id);
		idsMap.forEach(function (element, index, array) {
 		    // element: 指向当前元素的值
 		    // index: 指向当前索引
 		    // array: 指向Array对象本身modelIds
 			 idsList.push(element);
 		});
		
		var checkCount=0;
		var totalCoun=0;
		$('.childCheckbox').each(function(i, d){
			totalCoun++;
		})
		$('.checked').each(function(i, d){
			checkCount++;
		})
		if(checkCount==totalCoun){
			$('.select_all').children().addClass("checked");
			$('.select_all').children().children().attr("checked","checked"); 
		}
    });
    $(document).on('ifUnchecked', '.childCheckbox', function() {
    	$(this).removeAttr("checked","checked"); 
		$(this).parent().removeClass("checked");
		var id=$(this).val();
		idsList.length=0;
		idsMap.delete(id);
		idsMap.forEach(function (element, index, array) {
 		    // element: 指向当前元素的值
 		    // index: 指向当前索引
 		    // array: 指向Array对象本身modelIds
 			 idsList.push(element);
 		});
		$('.select_all').children().removeClass("checked"); 
		$('.select_all').children().children().removeAttr("checked"); 
    });
    
    
    $(document).on('ifChecked', '#send_now', function() {
    	sendTimeType=0;
    });
    $(document).on('ifChecked', '#send_timer', function() {
    	sendTimeType=1;
    });
    
    
    </script>
    <script>
        var path = "<%=path%>";
        var myDataTable;
        var access_token=$.cookie('access_token');
	   	var cid=$.cookie('cid');
	   	var uid=$.cookie('uid');
        var keyWord="";
        var orderBy="create_time desc";
        var idsMap=new Map();
        var idsList=new Array();
        var sendTimeType=0;
        var sendTime="";
        var type="";
        $.fn.dataTable.ext.errMode = 'none';
        $(function(){
        	var myDate = new Date();
        	//获取当前年
        	var year=myDate.getFullYear();
        	//获取当前月
        	var month=myDate.getMonth()+1;
        	var beforeMonth=myDate.getMonth();
        	var beforeYear=year;
        	//获取当前日
        	var day=myDate.getDate(); 
        	if(month>12){
        		year=year+1;
        		month=1;
        	}
        	if(beforeMonth==0){
        		beforeMonth=12;
        		beforeYear=beforeYear-1;
        	}
        	$("#sendTimer").val(year+"-"+month+"-"+day);
        	$('#sendTimer').datepicker({  
                 todayBtn : "linked",  
                 autoclose : true,  
                 todayHighlight : true, 
                 startDate : new Date()
            }).on('changeDate',function(e){  
             	
            });
        	
        	init();
        	
        });
        
        function init(){
        	myDataTable = dataTable();
        	
        }
        
        function func_dataTableReload(){
        	myDataTable.ajax.reload(function(){
        		$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green"});
        		$('input').iCheck('uncheck');
        	});
        }


        var checkNum=0;
        var totalNum=0;
        function dataTable(){
        	return $('#mydataTable').DataTable({
        		processing: true,
        		ordering: true,
        		searching: false,
        		info: true,
        		autoWidth: true,
        		lengthChange: false,
        		/* "order": [[ 2, "desc" ]], */
        	    language: {
        	    	emptyTable: '没有数据',
        	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
        			infoEmpty: '没有数据',
        			lengthMenu: '每页显示 _MENU_ 条记录',
        			loadingRecords: '正在加载数据....',
        			processing: '正在处理数据....',
        			zeroRecords: '没有找到匹配的记录',
        			paginate: {
        				first: '首页',
        				previous: '前页',
        				next: '后页',
        				last: '尾页'
        			}
        	    },
        	    order: [[4,'desc']],
        		pageLength: 10,
        	    pagingType: 'full_numbers',
        	    columnDefs: [{
        	         'targets' : [0,1,3,5],    //1,3,5不排序
        	         'orderable' : false
                },{
        			render: function(data, type, full) {
        				totalNum++;
        				if(isChecked(data)){
        					checkNum++;
        					return '<div class="checkbox i-checks" style="margin-left:8px;"><label class="is_checkd"><input checked="checked" class="childCheckbox" type="checkbox" value="'+data+'"></label></div>';
        				}else{
        					return '<div class="checkbox i-checks" style="margin-left:8px;"><label class="is_checkd"><input class="childCheckbox" type="checkbox" value="'+data+'"></label></div>';
        				}
                    },
        			targets: 0
        		},{
        			render: function(data, type, full) {
        				var result = "";
        				if(data == "0"){
        					result = '<td ><font color="#f8ac59">未提交审核</font></td>';
        				}else if(data=="1"){
        					result = "发送完毕";
        				}else if(data=="2"){
        					result = '<td style="color:red"><font color="red">审核中</td>';
        				}else if(data=="3"){
        					result = '<td class="caozuo">发送中</td>';
        				}else if(data=="4"){
        					result='<td id="non_approval" cause='+full.nonCause+' >审核未通过</td>'
        				}else if(data=="5"){
        					result='<td id="non_approval" cause='+full.nonCause+' >发送失败</td>'
        				}else if(data=="6"){
        					result='<td id="non_approval" cause='+full.nonCause+' >审核通过</td>'
        				}
                        return result;
                    },
        			targets: 3
        		},{
                    render: function(data, type, full) {
                        var result = "";
                        if(data !=null){
                            result = '<td >'+getLocalTime(data)+'</td>';
                        }
                        return result;
                    },
                    targets: 4
                },{
        			render: function(data, type, full) {
        				var result = "";
        				//自动化营销创建的数据
        				if(full.type==1){
        				    result+='<shiro:hasPermission name="information_send_many:send_out">';
        					result += '<a batchId="'+data+'"  class="caozuo send" ><font color="#ddd">派送</font></a>';
                            result+='</shiro:hasPermission>';
        					if(full.sendStatus==1||full.sendStatus==2||full.sendStatus==3||full.sendStatus==6){
                                result +='<shiro:hasPermission name="information_send_many:update">';
            					result += '<a batchId="'+data+'"  class="caozuo edit" href="javascript:;"><font color="#ddd">编辑</font></a>';
                                result+='</shiro:hasPermission>';
            				}else{
                                result +='<shiro:hasPermission name="information_send_many:update">';
            					result += '<a batchId="'+data+'"  class="caozuo edit" href="<%=path%>/view/sms/editSendContent?type=edit&id='+data+'">编辑</a>';
                                result+='</shiro:hasPermission>';
        					}
        					result+='<shiro:hasPermission name="information_send_many:copy">';
            				result += '<a batchId="'+data+'"  class="caozuo copy" ><font color="#ddd">复制</font></a>';
            				result+='</shiro:hasPermission>';
            				result+='<shiro:hasPermission name="information_send_many:delete">';
            				result += '<a batchId="'+data+'"  class="caozuo delete" onclick="javascript:deletedDialog(\''+data+'\');">删除</a>';
                            result+='</shiro:hasPermission>';
            				return result;
        				}else{
                            //短信群发自身创建的数据
        					if(full.sendStatus==6){
        					    //审核通过6
                                result+='<shiro:hasPermission name="information_send_many:send_out">';
            					result += '<a batchId="'+data+'"  class="caozuo send" data-toggle="modal" data-target="#myModal5" >派送</a>';
                                result+='</shiro:hasPermission>';
        					}else{
                                result+='<shiro:hasPermission name="information_send_many:send_out">';
            					result += '<a batchId="'+data+'"  class="caozuo send" ><font color="#ddd">派送</font></a>';
                                result+='</shiro:hasPermission>';
            				}
            				if(full.sendStatus==1||full.sendStatus==2||full.sendStatus==3||full.sendStatus==6){
                                result +='<shiro:hasPermission name="information_send_many:update">';
            					result += '<a batchId="'+data+'"  class="caozuo edit" href="javascript:;"><font color="#ddd">编辑</font></a>';
                                result+='</shiro:hasPermission>';
    	
            				}else{
                                result +='<shiro:hasPermission name="information_send_many:update">';
            					result += '<a batchId="'+data+'"  class="caozuo edit" href="<%=path%>/view/sms/editSendContent?type=edit&id='+data+'">编辑</a>';
                                result+='</shiro:hasPermission>';
            				}
                            result+='<shiro:hasPermission name="information_send_many:copy">';
            				result += '<a batchId="'+data+'"  class="caozuo copy" href="<%=path%>/view/sms/choseSendObject?type=copy&id='+data+'">复制</a>';
                            result+='</shiro:hasPermission>';
            				result+='<shiro:hasPermission name="information_send_many:delete">';
            				result += '<a batchId="'+data+'"  class="caozuo delete" onclick="javascript:deletedDialog(\''+data+'\');">删除</a>';
                            result+='</shiro:hasPermission>';
            				return result;
        				}
        				
        				
        				
                    },
        			targets: 5
        		}],
        	    columns: func_columns(),
        	    serverSide: true,
        	    ajax: {
        	    	contentType: 'application/json',
        	    	type: 'POST',
        	    	url: func_AjaxUrl(),
        	    	data: function(d){
        	    		d.keyWord=keyWord;
                        d.sendStatus=status;
                        d.orderBy=orderBy;
                        d.type=type;
        				return JSON.stringify(d);
        			}
        		}
        	    ,
        	    "initComplete": function(settings, json) {
        	    	$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
        	    	var info=myDataTable.page.info(); 
                    if(info.recordsTotal<1){
                        createDialog()
                    }
        	    }
        	}).on( 'draw', function () {
        		$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});

        		if(checkNum==totalNum){
        			$('.select_all').children().addClass("checked");
        			$('.select_all').children().children().attr("checked","checked"); 
        		}else{
        			$('.select_all').children().removeClass("checked"); 
        			$('.select_all').children().children().removeAttr("checked"); 
        		}
        		totalNum=0;
        		checkNum=0;
        		
        		
        	} );
        	
        }

        //时间戳转日期 yyyy-MM-dd HH:MM:SS
        function getLocalTime(timestamp) {
            var date = new Date(timestamp);
            return date.format("yyyy-MM-dd hh:mm:ss");
        }
        
       function createDialog(){
        	swal({
        		  title: '创建短信批次?',
        		  text: "您暂未创建短信批次，请尽快创建短信批次吧!",
        		  type: 'warning',
        		  showCloseButton: true,
        		  confirmButtonColor: '#1ab394',
        		  
        		  confirmButtonText: '立即创建'
        		}).then(function () {
        			intentCreate();
        		})
        }
        
        function func_AjaxUrl(){
        	return path+"/smsBatch/ajaxSmsBatchList";
        }
        /**
         *	设置列名，对应后台
         */
        function func_columns(){
        	var jsonArr = [
        		{"data":"id"},
        		{"data":"name"},
        		{"data":"sendNum"},
        		{"data":"sendStatus"},
        		{"data":"sendTime"},
        		{"data":"id"}
        	];
        	return jsonArr;
        }
        
   
        
        function search(){
        	keyWord=$('#keyWord').val();
        	func_dataTableReload();
        }
        
        function statusChange(){
        	status=$("#select_status  option:selected").val();
        	func_dataTableReload();
        }
        
        function typeChange(){
        	type=$("#selectType  option:selected").val();
        	func_dataTableReload();
        }
        

        
        function deletedDialog(id){
			swal({
				  title: '您确定要删除此批次短信吗?',
				  text: "删除后将无法恢复，请谨慎操作！",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#d33',
				  cancelButtonColor: '#3085d6',
				  confirmButtonText: '删除',
				  cancelButtonText:'取消'
				}).then(function () {
					deleteOne(id);
				})
		}
        //删除一个
        function deleteOne(id){
            var url=path+"/smsBatch/ajaxDeleteSmsBatch"
            $.post(url, {
                "id" : id
            }, function(data) {
                if (data.status == 200) {
                    func_dataTableReload();
                    successDialog("删除成功");
                }else {
                    errorDialog("删除失败",data.message);
                }
            });
        }
        
        function deletedBatchDialog(){
			swal({
				  title: '您确定要删除选中的短信批次吗?',
				  text: "删除后将无法恢复，请谨慎操作！",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#d33',
				  cancelButtonColor: '#3085d6',
				  confirmButtonText: '删除',
				  cancelButtonText:'取消'
				}).then(function () {
					deleteBatch();
				})
		}
        //批量删除
        function deleteBatch(){
            var ids=idsList.join(",");
            if(!StringEmpty(ids)){
                promptDialog("请选择要删除的短信批次");
            }else{
                var url=path+"/smsBatch/ajaxDeleteSmsBatchByBatch"
                $.post(url, {
                    "ids" : ids
                }, function(data) {
                    if (data.status == 200) {
                        func_dataTableReload();
                        successDialog("删除成功");
                        idsMap.clear();
                    } else {
                        errorDialog("删除失败",data.message);
                    }
                });
            }

        }
        
        function intentCreate(){
        	window.location.href='<%=path%>/view/sms/choseSendObject?type=create';
        }


        //点击发送日期排序
        $('.sendTotal').on('click',function(event){
        	var desc=$(this).attr('aria-sort');
        	if(desc=="nudefined"||desc==undefined)
        		orderBy="send_num asc";
        	if(desc=="ascending"){
        		orderBy="send_num desc";
        	}else if(desc=="descending"){
        		orderBy="send_num asc";
        	}
        	
        });
        //点击发送时间排序
        var flag=false;
        $('.sendTime').on('click',function(event){
        	var desc=$(this).attr('aria-sort');
        	if(desc=="nudefined"||desc==undefined)
        		orderBy="create_time asc";
        	if(desc=="ascending"){
        		orderBy="create_time asc";
        	}else if(desc=="descending"&&flag){
        		orderBy="create_time desc";
        	}else{
        		orderBy="create_time asc";
        	}
        	if(!flag)
        		flag=true;
        });
        
        function NonApproval(non_cause){
        	
        }
        
        
        $(document).on('click', '#non_approval', function() {
        	var non_cause=$(this).attr("cause");
        	if(!StringEmpty(non_cause)){
        		non_cause="无";
        	}
        	commomDialog("未通过原因",non_cause);
        });
        
        //判断是否勾选
        function isChecked(id){
        	var result=false;
        	for(var i in idsList){
        		if(idsList[i]==id){
        			result=true;
        			break;
        		}
        	}
        	return result;
        }
        function colseModal(){
        	$("#myModal5").modal("hide");
        }
        var smsid='';
        $(document).on('click', '.send', function() {
            smsid=$(this).attr("batchId");
        });

        //派送
        function sendBatch(){
        	colseModal();
        	sendTime=$('#sendTimer').val();
            var tempTime=$('#timestr').val();
            if(tempTime ==""){
                sendTime=sendTime+" 11:00:00";
            }else{
                sendTime=sendTime+" "+tempTime;
            }

            var stime=new Date(sendTime);
        	var url=path+"/smsBatch/ajaxSocialSmsSend"
        	$.post(url, {
				"id" : smsid,
				"sendTimeType":sendTimeType,
                "sendTime":stime
			}, function(data) {
				if (data.status == 200) {
					func_dataTableReload();
					successDialog("派送成功");
				} else {
					errorDialog("派送失败",data.message);
				}
			});
        }
        
    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>


    <script type="text/javascript">
        Date.prototype.format = function(fmt) {
            var o = {
                "M+" : this.getMonth()+1,                 //月份
                "d+" : this.getDate(),                    //日
                "h+" : this.getHours(),                   //小时
                "m+" : this.getMinutes(),                 //分
                "s+" : this.getSeconds(),                 //秒
                "q+" : Math.floor((this.getMonth()+3)/3), //季度
                "S"  : this.getMilliseconds()             //毫秒
            };
            if(/(y+)/.test(fmt)) {
                fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
            }
            for(var k in o) {
                if(new RegExp("("+ k +")").test(fmt)){
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
                }
            }
            return fmt;
        }
    </script>
</body>
</html>
